﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="recvers.ascx.cs" Inherits="basecon_recvers" %>
<div>
    <a id="aSelectRecvers" href="javascript:void(0)"><span id="spRecversNum">0</span>名收件人</a></div>
<div id="divRecvers" class="divRecvers">
    <div class="close">
        <asp:Image ID="imgX" runat="server" /></div>
    <asp:HiddenField ID="hidUserGuid" runat="server" />
    <asp:HiddenField ID="hidRecvers" runat="server" />
    <asp:HiddenField ID="hidEnableEdit" runat="server" />
    <asp:HiddenField ID="hidRvHtml" runat="server" />
    <div id="divRecversContainer" class="divRecversContainer">
        <p>
            <input type="checkbox" id="cbSelectAll" />全选</p>
        <div id="divRecversTab">
            <%
                //Response.Write(this.Rv.ToHTML());
                Response.Write(this.RvHtml);
            %>
        </div>
        <p>
            <input type="button" value="选择" id="btnSelectRecvers" />
        </p>
    </div>

    <script type="text/javascript">
    var r="#<%=this.hidRecvers.ClientID %>";
    var imgOpenUrl="<%Response.Write(Params.ImagesFolderHttp+"mylist_open_btn.gif"); %>";
    var imgCloseUrl="<%Response.Write(Params.ImagesFolderHttp+"mylist_close_btn.gif"); %>";
    $(document).ready(function() {
        $("#btnSelectRecvers").click(function(){
            var guids="";
            var n=0;
            $("#divRecversContainer input[type='checkbox']").each(function(){
                if($(this).attr("checked")==true)
                {
                    if($(this).attr("guid")!="0"&&$(this).attr("guid")!=""&&$(this).attr("guid")!=null)
                    {
                        guids=guids+" "+$(this).attr("guid");
                        n++;
                    }
                }
            });
            //alert(guids);
            $("#spRecversNum").html(n);
            $(r).val(guids);
            $.unblockUI();
        });
        $("#cbSelectAll").click(function(){
            var b=$(this).attr("checked");
            $("#divRecversContainer input[type='checkbox']").each(function() { 
                $(this).attr("checked", b); 
            });
        });
        $("#aSelectRecvers").click(function(){$.blockUI({ message: $("#divRecvers"),target: "#form1",css:{top:"30px"} });});
        $("#divRecversContainer input[guid='0']").click(function(){
            var b=$(this).attr("checked");
            $(this).parent().parent().find("input[type='checkbox']").each(function() { 
                $(this).attr("checked", b); 
            });
        });
	    $(".close").click(function(){
            var guids="";
            var n=0;
            $("#divRecversContainer input[type='checkbox']").each(function(){
                if($(this).attr("checked")==true)
                {
                    if($(this).attr("guid")!="0"&&$(this).attr("guid")!=""&&$(this).attr("guid")!=null)
                    {
                        guids=guids+" "+$(this).attr("guid");
                        n++;
                    }
                }
            });
            //alert(guids);
            $("#spRecversNum").html(n);
            $(r).val(guids);
            $.unblockUI();
	    });
	    if($(r).val()!="")
	    {
	        var guids=$(r).val().split(" ");
	        //alert(guids.length);
	        var i=0;
	        var n=0;
	        for(i=0;i<guids.length;i++)
	        {
	            var s="#divRecversContainer input[guid='"+guids[i]+"']";
	            if($(s).length>0)
	            {
	                $(s).attr("checked",true);
	                n++;
	            }
	        }
            $("#spRecversNum").html(n);
	        
	    }
	    if(!<%=this.EnableEdit?"true":"false" %>)
	    {
	        $("#divRecvers input").each(function(){$(this).attr("disabled","disabled");});
	    }
    });
    function OpenNextDiv(obj)
    {
        if($(obj).attr("src")==imgOpenUrl)
        {
        //alert($(obj).parent().parent().find("div").length);
            $(obj).attr("src",imgCloseUrl);
            $(obj).parent().parent().find(">div").show();
        }
        else if($(obj).attr("src")==imgCloseUrl)
        {
            $(obj).parent().parent().find(">div").hide();
            $(obj).attr("src",imgOpenUrl);
        }
    }
    </script>

</div>
